package manager;

import remoteEntity.Download;
import remoteEntity.Log;
import facade.DownloadFacade;
import facade.LogFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 * LogManager
 *
 * Handles log and download history functionality.
 */
@Stateless
@LocalBean
public class LogManager implements LogManagerRemote{

    @EJB
    private LogFacade logFacade;
    @EJB
    private DownloadFacade downloadFacade;

    @Override
    public List<Log> getAllPosts() {
        return logFacade.findAll();
    }

    @Override
    public void logDebug(String page, String msg) {
        logFacade.log(page, msg, "debug");
    }

    @Override
    public void logInfo(String page, String msg) {
        logFacade.log(page, msg, "info");
    }

    @Override
    public void logWarning(String page, String msg) {
        logFacade.log(page, msg, "warning");
    }

    @Override
    public void logError(String page, String msg) {
        logFacade.log(page, msg, "error");
    }

    @Override
    public void logDownload(int userId, int downloadId) {
        downloadFacade.logDownload(userId, downloadId);
    }
    
    //TODO: add in remote interface
    //@Override
    public List<Download> getDownladsForUser(int id) {
        return downloadFacade.getDownloadsForUser(id);
    }

    @Override
    public String testMethod() {
        return "Test string from LogManager in filecityee manager package";
    }
}
